<template>
	<section>
		<main>
			<mt-header fixed title="消息详情">
				<mt-button slot="left" icon="back"  @click="goBack">
					<a class="white" href="javascript:;">返回</a>
				</mt-button>
			</mt-header>
			<div class="ml10 mr10">
				<div class="mt50">
					<h3 class="lh40 fs14 bold">{{data.pushTopic || data.title}}</h3>
					<p class="lh25 fontc3">{{data.createTime}}</p>
				</div>
				<img v-show="data.cover" :src="data.cover" alt="">
				<p class="detail mt20 lh20 fs14 tl" v-show="data.pushMsg" v-html="data.pushMsg"></p>
				<p class="detail mt20 lh20 fs14 tl" v-show="data.content" v-html="data.content"></p>
			</div>
		</main>
	</section>
</template>
<script>

import axios from 'axios'
import {MessageBox,Toast,Indicator} from 'mint-ui'
export default {
	name : "NewsDetail",
	data () {
		return {
			data : {},
		}
	},
	created () {
		console.log();
		if (this.$route.query.pram) {
			this.getNewsDetail(this.$route.query.pram);
		};
		if (this.$route.query.id) {
			this.getInfoDetail(this.$route.query.id);
		};

		if (this.$route.query.safe) {
			this.getBaseSafe(11);
		};

		if (this.$route.query.base) {
			this.getBaseSafe(12);
		};
	},
	methods : {
		getInfoDetail (id,url) {

			axios({
				method: "post",
				url: '/user/news/getInfoById.do',
				params: {
					id: id,
					pushType : 2
				}
			})
			.then((res) => {
				Indicator.close();
				res = res.data;
				if (res.code == 200) {
					this.data = res.data;
				} else {
					Toast(res.msg);
				}
			})
		},
		getNewsDetail (parm) {
			axios({
				method: "get",
				url: '/user/news/findNews.do',
				params: {
					id: parm,
				}
			})
			.then((res) => {
				Indicator.close();
				res = res.data;
				if (res.code == 200) {
					this.data = res.data;
				} else {
					Toast(res.msg);
				}
			})
		},
		getBaseSafe (id) {
			Indicator.open('加载中');
			axios({
				method: "get",
				url: '/user/news/findPlatformNewsList.do?offset=0&size=20',
				params: {
					type: id,
				}
			})
			.then((res) => {
				Indicator.close();
				res = res.data;
				if (res.code == 200) {
					console.log(res);
					
					this.data = res.data[0];
				} else {
					Toast(res.msg);
				}
			})
		},
		goBack () {
			window.history.length > 1 ? this.$router.go(-1) : this.$router.push('/');
		}
	}
}
</script>
<style scoped>
	.detail{
		text-indent: 2em;
	}
</style>









